package com.idlefish.flutterboost;

import android.util.Log;

import com.idlefish.flutterboost.intef.MethodCallAction;

public class MethodCallManager {

    private static final String ACTION_PACKAGE_NAME =  "com.idlefish.flutterboost.action.MethodAction";


    public static <T extends MethodCallAction> T getClassForTarget(String target) {
        T t = null;
        try {
            Class tClass = getClassTarget(target);
            if (tClass != null) {
                Class tName = Class.forName(tClass.getName());
                t = (T) tName.newInstance();
            }
        } catch (Exception tx) {
            Log.e("MethodCallManager",tx.getMessage());
        }
        return t;
    }
    private static Class getClassTarget(String target) {
       try {
           return Class.forName(ACTION_PACKAGE_NAME + target.substring(0, 1).toUpperCase() + target.substring(1));
       }catch (Exception ignore){

       }
        return null;
    }

}
